<template>
    <section class="wrapper">
      <myHeader :obj="myObj" @events="events"></myHeader>
      <main>
        <myNameCard :borderB="true" :faceUrl="myDate.HeadUrl">
          <span slot="name">{{myDate.Name}}</span>
          <span slot="info">{{myDate.Job}}</span>
          <span slot="area">{{myDate.Introduce}}</span>
        </myNameCard>
        <div class="selTitle_0313">选择该行家话题</div>
        <div class="itemWrap_0313">
          <div class="themeItem_0313" v-for="(item,index) in dataList" @click="selecttheme(index,item.PostMesssageDetailId)">
            <div class="itemText_0313">{{item.Title}}</div>
            <div class="isSelect_0313" :class="active == index?'activeBlue_0315':''"></div>
          </div>
        </div>
        <myButton class="marginTB" @sendDate="CreateMeetDeal">提交</myButton>
      </main>
    </section>
</template>
<script>
import myHeader from './base/myHeader';
import myButton from './base/myButton';
import myNameCard from './base/myNameCard';
import hgjSkip from '../assets/js/hgjSkip';
import API from '../assets/js/asktoses';
import { fetch } from '../assets/api';
import {Toast } from 'mint-ui';
export default {
  data () {
    return {
      myObj: {
        type: 2,
        text: '求见行家'
      },
      dataList:{},
      active:0,
      DetailId:null,//订单编号
      loginData:null,
      myDate:"",
    }
  },
  created() {
    hgjSkip.skip().then(res =>{
      this.loginData = res;
      this.themelist();
      this.myself();
    })
  },
  methods: {
    events(i){
      if(i == 2) {
        history.back();
      }
    },
    //选择主题
    selecttheme(num,id) {
      this.active = num;
      this.DetailId = id;
    },
    //行家提交订单
    async CreateMeetDeal(){
      this.DetailId = this.DetailId == null?this.dataList[0].PostMesssageDetailId:this.DetailId;
      const res = await fetch(API.getAskToSee,{
        ...this.loginData[1],
        PostMesssageDetailId:this.DetailId,
        AskToSesApplyId:this.$route.query.Id,
      });
      this.$router.push({path:'/indentFinish',query:{Id:res.Result}})
    },
    async myself(){
      let res = await fetch(API.getexpert,{
        OpenId:this.$route.query.openid,
        Sig:this.loginData[1].Sig,
      });
      this.myDate = res.Result
    },
    //查询行家可约见标题列表
    async themelist(){
      const res = await fetch(API.expertCanAppointmentList,{
        OpenId:this.$route.query.openid,
        Sig:this.loginData[1].Sig,
      });
      this.dataList = res.Result;
    },
  },
  components: {
    myHeader,
    myButton,
    myNameCard
  }
}

</script>
<style lang="less">
  .wrapper {
    width: 3.75rem;
    height: 100%;
    main {
      width: 3.75rem;
      height: 100%;
      padding-top: .44rem;
      position: absolute;
      top: 0;
      left: 0;
      overflow-y: auto;
      box-sizing: border-box;
      .marginTB {
        margin: .9rem auto .4rem;
      }
      .itemWrap_0313 {
        padding: 0 .15rem;
        background: white;
        .themeItem_0313 {
          height: .53rem;
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: .1rem 0;
          box-sizing: border-box;
          color: black;
          font-size: .17rem;
          background: white;
          font-weight: 600;
          border-bottom: .01rem solid #E5E5E5;
          &:nth-last-child(1) {
            border-bottom: none;
          }
          .itemText_0313 {
            width: 2.5rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          .isSelect_0313 {
            width: .2rem;
            height: .2rem;
            background: url('../assets/img/group/no-select.png') center center;
            background-size: cover;
            background-repeat: no-repeat;
          }
          .activeBlue_0315 {
            background: url('../assets/img/expert/icon_yes@3x.png') center center;
            background-size: cover;
            background-repeat: no-repeat;
          }
        }
      }
      .selTitle_0313 {
        padding: .15rem;
        font-size: .13rem;
        color: #999999;
        background: white;
      }
    }

  }
</style>
